package com.jt.proxy;

import com.jt.pojo.User;
import com.jt.service.UserService;
import jdk.internal.org.objectweb.asm.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

/**
 * @author 无情吕布丶
 * @date 2021/4/25 11:35
 */
@Service("userService")
public class StaticProxy implements UserService {


    //要求引入目标对象
    @Autowired
    //@Qualifier("target")
    private UserService target;

    //扩展方法
    @Override
    public void addUser(User user) {

        try {
            System.out.println("事物开始");
            target.addUser(user);
            System.out.println("事务提交");

        }catch (Exception e){
            e.printStackTrace();
            System.out.println("事务回滚");
        }
    }

    @Override
    public void deleteUser(User user) {
        //测试
    }
}
